//
//  JMHomeFicoView.m
//  NewiOSProject
//
//  Created by JMMac on 24.12.23.
//  Copyright © 2023 范智渊. All rights reserved.
//

#import "JMHomeFicoView.h"

@implementation JMHomeFicoView
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self = [[UIView alloc]initWithFrame:frame];
        self.backgroundColor = Hex_Str_COLOR(@"#ffffff");
        
        
        
        UILabel *soloLab = [JMControl createLabelWithFrame:(CGRectMake(0, 10, 150, 24)) Font:fontWithWeight(17, UIFontWeightMedium) Text:@"Aumentar la cuota" color:Hex_Str_COLOR(@"#222222")];
        [self addSubview:soloLab];
        soloLab.backgroundColor = WhiteColor();
        soloLab.textAlignment = 1;
        soloLab.centerX = kAppW()/2;
        
        UIView *lineV = [[UIView alloc]initWithFrame:(CGRectMake(0, 0, 198, 2))];
        lineV.backgroundColor = Hex_Str_COLOR(@"#3C57F8");
        [self addSubview:lineV];
        [self sendSubviewToBack:lineV];
        lineV.center = soloLab.center;
        
        
        UIView *contentV = [[UIView alloc]initWithFrame:(CGRectMake(9, soloLab.bottom+16, kAppW()-18, 105))];
        contentV.backgroundColor = Hex_Str_COLOR(@"#26A2FA");
        [self addSubview:contentV];
        contentV.cornerRadius = 4;
        
        UIImageView *rightImgV = [[UIImageView alloc]initWithFrame:(CGRectMake(self.width-ScaleW(120), 14, ScaleW(82), ScaleW(80)))];
        rightImgV.image = ImageNamed(@"home_fico");
        [contentV addSubview:rightImgV];
        
        UILabel * integralSubTitleLab = [JMControl createLabelWithFrame:CGRectMake(21, 20, self.width-50-rightImgV.width, 44) Font:Font(16) Text:@"¿Quieres aumentar tu saldo rápidamente?  " color:Hex_Str_COLOR(@"#ffffff")];
        integralSubTitleLab.numberOfLines = 0;
        [contentV addSubview:integralSubTitleLab];

        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:integralSubTitleLab.text];
        attr.yy_font = [UIFont systemFontOfSize:16];

        UIImageView *detailImgV = [[UIImageView alloc]initWithFrame:(CGRectMake(0, 0, 15, 15))];
        detailImgV.image = ImageNamed(@"home_right_white");
        NSTextAttachment *yearAttchment00 = [[NSTextAttachment alloc]init];
        yearAttchment00.bounds = CGRectMake(0, 0, 15, 15);
        yearAttchment00.image = detailImgV.image;
        
        NSAttributedString *yearString00 = [NSAttributedString attributedStringWithAttachment:(NSTextAttachment *)(yearAttchment00)];
        [attr insertAttributedString:yearString00 atIndex:attr.length];
        integralSubTitleLab.attributedText = attr;
     
        
        UILabel * integralTitleLab = [JMControl createAutoHeightLabelWithOrgin:(CGPointMake(integralSubTitleLab.left, integralSubTitleLab.bottom)) andWidth:ScaleW(183) Font:[UIFont systemFontOfSize:12]  Text:@"Intenta autorizar para obtener el informe de Fico" color:Hex_Str_COLOR(@"#ffffff")];
        [contentV addSubview:integralTitleLab];
        integralTitleLab.numberOfLines = 0;
       

        @weakify(self)
        [self tapAction:^(UIView *sender) {
            @strongify(self);
            [JMCommonMethod uploadStatistics:nil actionType:nil parameters:nil];
        }];
    }
    return self;
}
@end
